package com.persondemo.videoappliction.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.persondemo.videoappliction.R;
import com.persondemo.videoappliction.bean.MainBean;
import com.persondemo.videoappliction.utils.T;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/3/26.
 */

public class MainGridViewAdapter extends BaseAdapter {
    private Context mContext;

    /**
     * 每个分组下的每个子项的 GridView 数据集合
     */
    private List<MainBean.DataBean.TypeslistBean> itemGridList;

    public MainGridViewAdapter(Context mContext, List<MainBean.DataBean.TypeslistBean> itemGridList) {
        this.mContext = mContext;
        this.itemGridList = itemGridList;

    }

    @Override
    public int getCount() {
        return itemGridList.size()>0?itemGridList.size():0;
    }

    @Override
    public Object getItem(int position) {
        return itemGridList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (null == convertView) {
            convertView = View.inflate(mContext, R.layout.gridview_item, null);
        }
        TextView tvGridView = (TextView) convertView.findViewById(R.id.tv_gridview);
        tvGridView.setText(itemGridList.get(position).getTypes_name());
//        tvGridView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                T.showShort(mContext, itemGridList.get(position).getTypes_name());
//
//            }
//        });
        return convertView;
    }
}